#include<string>
#include<vector>
#include<array>
#include<unordered_map>
#include<algorithm>
#include<limits>
#include <stack>
#include<iostream>
#include<sstream>
#include<deque>
#include<queue>
#include<set>
#include<unordered_set>
#define MOD 1000000007
class Solution {
public:
    int numDistinct(std::string s, std::string t) {
        int n = s.size();
        int m = t.size();
        std::vector<uint64_t> dp(t.size()+1,0);
        dp[0] = 1;
        uint64_t pre =1;
      uint64_t cur = 0;
        for (int i=1;i<=n;i++)
        {
            for (int j=1;j<=m;j++) 
            {
                pre =cur;
                cur = dp[j];
                if(s[i-1]==t[j-1]){
                    dp[j] += pre;
                }
            }
        }
        return dp[m];
    }
};
int main()
{
    Solution s;
    s.numDistinct("rarara","ra");
}